﻿@page "/"
@using ComputerLock.Enums
@using JiuLing.CommonLibs.ExtensionMethods

<style>
    .dialog-blurry {
        backdrop-filter: blur(10px);
    }
</style>

<MudSwitch @bind-Value="@(AppSettings.IsDisableWindowsLock)"
           @bind-Value:after="SaveSettings"
           Label="@(Lang["DisableWindowsLock"])"
           Color="Color.Primary" />

<MudSwitch @bind-Value="@(AppSettings.LockAnimation)"
           @bind-Value:after="SaveSettings"
           Label="@(Lang["LockAnimation"])"
           Color="Color.Primary" />

<div class="d-flex align-center">
    <MudSwitch @bind-Value="@(AppSettings.EnablePasswordBox)"
               @bind-Value:after="SaveSettings"
               Label="@(Lang["EnablePasswordBox"])"
               Color="Color.Primary" />
    @if (!AppSettings.EnablePasswordBox)
    {
        <MudChip T="string"
                 Label="true"
                 Icon="@Icons.Material.Filled.WarningAmber"
                 IconColor="Color.Primary"
                 DisableRipple="true"
                 Size="Size.Small">
            @(Lang["EnablePasswordBoxTips"])
        </MudChip>
    }
</div>

<MudSwitch @bind-Value="@(AppSettings.IsHidePasswordWindow)"
           @bind-Value:after="SaveSettings"
           Class="ml-6"
           Disabled="@(!AppSettings.EnablePasswordBox)"
           Label="@(Lang["HidePasswordWindow"])"
           Color="Color.Primary" />

<MudSwitch @bind-Value="@(_keyboardDownChecked)"
           @bind-Value:after="KeyboardDownChecked"
           Class="ml-6"
           Disabled="@(!AppSettings.EnablePasswordBox)"
           Label="@(Lang["KeyboardDownActivePwd"])"
           Color="Color.Primary" />

<MudSwitch @bind-Value="@(_mouseDownChecked)"
           @bind-Value:after="MouseDownChecked"
           Class="ml-6"
           Disabled="@(!AppSettings.EnablePasswordBox)"
           Label="@(Lang["MouseDownActivePwd"])"
           Color="Color.Primary" />

<MudSwitch @bind-Value="@(AppSettings.LockOnStartup)"
           @bind-Value:after="SaveSettings"
           Label="@(Lang["LockOnStartup"])"
           Color="Color.Primary" />

<div class="d-flex align-center mt-2">
    <MudText Typo="Typo.button">@(Lang["LockShortcutKey"])</MudText>
    <MudButton Class="ml-3"
               Variant="Variant.Text"
               Size="Size.Small"
               Color="Color.Primary"
               OnClick="SetShortcutKey">
        @(_shortcutKeyText)
    </MudButton>
    @if (AppSettings.ShortcutKeyForLock.IsNotEmpty())
    {
        <MudTooltip Text="删除快捷键" Delay="600">
            <MudIconButton Icon="@Icons.Material.Filled.Delete"
                           Size="Size.Small"
                           OnClick="ClearShortcutKey" />
        </MudTooltip>
    }
</div>

<MudGrid>
    <MudItem xs="6">
        <MudNumericField T="int"
                         Label="@(Lang["AutoLock"])"
                         Value="@(AppSettings.AutoLockMinute)"
                         Min="0"
                         Class="mt-4"
                         ValueChanged="AutoLockChanged">
        </MudNumericField>
    </MudItem>
    <MudItem xs="6">
        <MudSelect T="ScreenLocationEnum"
                   Label="@(Lang["PwdLocation"])"
                   Value="@(AppSettings.PasswordInputLocation)"
                   Disabled="@(!AppSettings.EnablePasswordBox)"
                   Class="mt-4"
                   ValueChanged="PwdBoxLocationChanged"
                   Dense="true">
            <MudSelectItem Value="@(ScreenLocationEnum.Center)">@(Lang["Center"])</MudSelectItem>
            <MudSelectItem Value="@(ScreenLocationEnum.TopLeft)">@(Lang["TopLeft"])</MudSelectItem>
            <MudSelectItem Value="@(ScreenLocationEnum.TopRight)">@(Lang["TopRight"])</MudSelectItem>
            <MudSelectItem Value="@(ScreenLocationEnum.BottomLeft)">@(Lang["BottomLeft"])</MudSelectItem>
            <MudSelectItem Value="@(ScreenLocationEnum.BottomRight)">@(Lang["BottomRight"])</MudSelectItem>
        </MudSelect>
    </MudItem>
</MudGrid>

<div class="d-flex align-center mt-4">
    <MudButton Class="mr-3"
               Variant="Variant.Text"
               Size="Size.Small"
               Color="Color.Primary"
               OnClick="SetPassword">
        @(Lang["SetPassword"])
    </MudButton>
    @if (!AppSettings.IsPasswordChanged)
    {
        <MudText Typo="Typo.caption">@(Lang["PasswordTip"])</MudText>
    }
</div> 